feat: restore legacy anchor alias to preserve old links#699
feat: restore legacy anchor alias to preserve old links#699avivkeller merged 2 commits intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #699 +/- ##
==========================================
+ Coverage 75.44% 75.52% +0.07%
==========================================
Files 148 150 +2
Lines 13572 13697 +125
Branches 1023 1041 +18
==========================================
+ Hits 10239 10344 +105
- Misses 3328 3348 +20
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
avivkeller
left a comment
There was a problem hiding this comment.
Any and all legacy slug generation should go in the legacy generator, not the metadata generator
1eec08d to
9f06c83
Compare
|
@avivkeller I've updated the PR to remove the legacy logic from the metadata/jsx-ast generators completely. All the legacy slug generation and its tests are now strictly isolated within the legacy-html generator as requested. Let me know if there's anything else that needs adjusting! |
9f06c83 to
592ee66
Compare
592ee66 to
aeeb9d2
Compare
aeeb9d2 to
8e5017f
Compare
|
@shivxmsharma can you amend your commits to add me as a co author? |
Co-authored-by: Aviv Keller <me@aviv.sh>
bb4733a to
f4292a9
Compare
Done! I've amended the commit to include you as a co-author. |
Fixes: #697
Description
Restores the legacy anchor alias for headings to preserve old documentation links.
The old Node.js doc generator (
tools/doc/html.mjs) produced two anchor IDs per heading — a modern GitHub-style slug (e.g.,#file-system) and a legacy underscore-based slug prefixed with the filename (e.g.,#fs_file_system). External sites like Express and many others still link to these legacy anchors, and since doc-kit dropped them, those links silently break.This PR ports the old
getLegacyIdalgorithm into doc-kit and renders a hidden<a>element with the legacy ID alongside every heading, so both old and new anchor links resolve correctly.Changes
src/generators/metadata/utils/slugger.mjs— AddedgetLegacySlug()function implementing the old underscore-based slug algorithm, and added alegacySlug()method tocreateNodeSluggerwith counter-based deduplication.src/generators/metadata/types.d.ts— AddedlegacySlug: stringfield toHeadingDatainterface.src/generators/metadata/utils/parse.mjs— GeneratelegacySlugfor every heading during metadata parsing.src/generators/legacy-html/utils/buildContent.mjs— Render a hidden legacy anchor<a>element in the legacy HTML output.src/generators/jsx-ast/utils/buildContent.mjs— Render a hidden legacy anchor<a>element in the JSX/AST (web) output.src/generators/metadata/utils/__tests__/slugger.test.mjs— Added tests forgetLegacySlugandcreateNodeSlugger.legacySlug.Validation
npm test).npm run lint,npm run format:check).fs.mdfile confirms both anchors are present:<a id=fs_file_system></a>(legacy) alongside<a class=mark id=file-system>(modern)<a id=fs_fs_readfile_path></a>(legacy) alongside<a class=mark id=fsreadfilepath>(modern)Related Issues
Fixes #697
Check List
node --run testand all tests passed.node --run format&node --run lint.